<?php
class ChannelService extends BaseDbService
{
	public function __construct()
	{
		$this->dao				= new ChannelDao();
	}
	
	public function getList($start,$num,$orderby='',$fields='id,name,url,updated')
	{
		$condition				= array();
		$result['count'] 		= $this->dao->count($condition);
		
		if($result['count']>0)
		{
			if($num>0)
			{
				$condition['limit'] 	= $num;
			}
			if($start>=0)
			{
				$condition['offset'] 	= $start;
			}
			if($orderby=='')
			{
				$orderby			= 'updated DESC';
			}
			$condition['orderby'] 	= $orderby;
			if($fields!='')
			{
				$condition['fields']	= $fields;
			}
			$result['rows'] 			= $this->dao->fetchRows($condition);
		}
		else
		{
			$result['rows'] 		= false;
		}
		
		return $result;
	}
	
	public function getByUrl($url)
	{
		$condition['expression']	= 'url=:url';
		$condition['value']['url']	= $url;
		$result = $this->fetch($condition);
		
		return $result;
	}
}
?>